package com.yoyo.series.app;

import android.content.Intent;
import android.os.Bundle;

import com.actionbarsherlock.app.SherlockActivity;
import com.yoyo.series.activity.MainActivity;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;

public abstract class BaseActivity extends SherlockActivity {

    protected ImageLoader mImageLoader;
    protected DisplayImageOptions mOptions;
    
    
    public BaseActivity() {
        mImageLoader = ImageLoader.getInstance();
    }
    
    protected abstract void initializeData();
    
    protected abstract void initializeViews();
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        mOptions = (new com.nostra13.universalimageloader.core.DisplayImageOptions.Builder()).cacheInMemory().cacheOnDisc().build();
        setContentView();
        initializeData();
        initializeViews();
    }
    
    protected abstract void setContentView();
    
    protected void setContentView(int i, boolean flag) {
        setContentView(i);
    }
    
    protected void restartApplication()
    {
        finish();
        Intent intent = new Intent(getApplicationContext(), MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        intent.putExtra("restart_app", true);
        startActivity(intent);
    }
}
